package com.mall.web.service;

import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mall.untils.MapUtil;

@Service
public class TestYCSService {
	private Logger logger=LoggerFactory.getLogger(TestYCSService.class);
	@Resource JdbcTemplate jdbcTemplate;
		
	@Transactional
	public String saveA(Map<String, Object> param){
		String data="1";
			String uid=MapUtil.getStringValue(param, "uid");
			String name=MapUtil.getStringValue(param, "name");
			String sql1="insert into tb_test_ycs1(uid) values (?)";
			String sql2="insert into tb_test_ycs2(name) values (?)";
			
			jdbcTemplate.update(sql1, uid);
			jdbcTemplate.update(sql2, name);
		return data;
	}
	
	@Transactional
	public String saveMo(Map<String, Object> param){
		String data="1";
		String type=MapUtil.getStringValue(param, "type");
		String orderType=MapUtil.getStringValue(param, "orderType");
		if("success".equals(type)&&"1".equals(orderType)){
			String uid=MapUtil.getStringValue(param, "orderId");
			String sql1="insert into tb_test_ycs1(uid) values (?)";
			jdbcTemplate.update(sql1, uid);
		}else{
			data="2";
		}
		return data;
	}
	
	@Transactional
	public String saveNo(Map<String, Object> param){
		String data="1";
		String type=MapUtil.getStringValue(param, "type");
		String orderType=MapUtil.getStringValue(param, "orderType");
		System.out.println("type"+type);
		if("success".equals(type)&&"1".equals(orderType)){
			String uid=MapUtil.getStringValue(param, "orderId");
			String sql1="insert into tb_test_ycs1(uid) values (?)";
			jdbcTemplate.update(sql1, uid);
		}else{
			data="2";
		}
		
		return data;
	}

}
